package com.itrencai.d6_set;

import java.util.HashSet;
import java.util.Set;

//目标：让set集合把重复内容的对象去掉一个
public class SetDemo3quchongfu {
    public static void main(String[] args) {
        //Set集合去重复原因，先判断哈希值，再判断equals
        Set<Student> sets=new HashSet<>();
        Student s1=new Student("李华",20,'男');
        Student s2=new Student("李华",20,'男');
        Student s3=new Student("小红",24,'女');
        System.out.println(s1.hashCode());//两个对象内容一样，返回的哈希值一样
        System.out.println(s2.hashCode());
        System.out.println(s3.hashCode());
        sets.add(s1);
        sets.add(s2);
        sets.add(s3);
        System.out.println(sets);
    }
}
